<template>
    <div class="login">
        <div class="login_btn">
            <input
                type="text"
                placeholder-style="color: #FFC4DB;"
                class="inputStyle"
                placeholder="请填写手机号"
                v-model.trim="loginInf.mobile"
            />
            <input
                type="password"
                placeholder-style="color: #FFC4DB;"
                class="inputStyle"
                placeholder="请填写密码"
                v-model.trim="loginInf.pwd"
            />
            <button class="login_btn_t" @click="login">登录</button>
        </div>
        <div class="login_ck">
            <span @click="go">已阅读并同意《微语医疗用户协议》</span>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            loginInf: {
                mobile: "",
                pwd: ""
            }
        };
    },
    mounted() {},
    methods: {
        go() {
             uni.navigateTo({
                url: "docx",
                animationType: "pop-in",
                animationDuration: 200
            });
        },
        handleLogin() {
            var url = "../index/index"; // 登录跳转页面
            uni.reLaunch({
                url: url
            });
        },
        login() {
            var _this = this;
            if (_this.loginInf.mobile) {
                const reg = /^1[0-9][0-9]\d{8}$/;
                if (!reg.test(_this.loginInf.mobile)) {
                    return uni.showToast({
                        title: "手机号格式错误！",
                        icon: "none"
                    });
                }
            } else {
                return uni.showToast({
                    title: "请输入手机号！",
                    icon: "none"
                });
            }
            if (!_this.loginInf.pwd) {
                return uni.showToast({
                    title: "请输入密码！",
                    icon: "none"
                });
            }
            this.$ajaxs
                .get("/mobile/v1/users/loginByMobileAndPwd", _this.loginInf)
                .then(res => {
                    if (res.status === 200) {
                        uni.showToast({
                            title: "登录成功",
                            icon: "success"
                        });
                        uni.setStorage({
                            //存储到本地
                            key: "token",
                            data: res.content
                        });
                        _this.handleLogin();
                    } else {
                        uni.showToast({
                            title: res.message,
                            icon: "none"
                        });
                        return false;
                    }
                });
        }
    }
};
</script>

<style>
.inputStyle {
    border: 1px solid #ffc6dd;
    font-size: 28upx;
    padding-left: 40upx;
    border-radius: 48upx;
    /* width: 578upx; */
    height: 80upx;
    background: #fff5f9;
    margin-bottom: 28upx;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}
.card {
    padding: 20upx;
}
.login {
    height: 100%;
    width: 100%;
    font-family: PingFang-SC-Medium;
}
.col-class {
    margin-bottom: 40upx;
}
.icimgs {
    height: 200upx;
    width: 200upx;
    border-radius: 50%;
    margin: 0 auto;
}
.imgcenter {
    text-align: center;
    margin-bottom: 40upx;
}
.class_img {
    padding: 124upx 34upx 64upx 32upx;
}
.class_img .by_img {
    width: 100%;
    min-height: 620upx;
}
.login_btn {
    padding: 0 80upx 20upx 80upx;
    margin-top: 100upx;
}
.login_btn .login_btn_t,
.login_btn_o {
    background: #fff;
    border: 1px solid #f75193;
    /* width: 620upx; */
    height: 84upx;
    text-align: center;
    line-height: 80upx;
    border-radius: 48upx;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    color: #f75193;
}
.login_btn_o {
    margin-top: 36upx;
}
.login_ck {
    height: 34upx;
    font-size: 24upx;
    font-weight: 500;
    color: rgba(153, 153, 153, 1);
    line-height: 34upx;
    text-align: center;
}
.login_ck .checks {
    font-size: 38upx;
}
</style>